package com.yzh.openai.domain.openai.service.channel.factory;

import com.yzh.openai.domain.openai.model.aggregates.ChatProcessAggregate;
import com.yzh.openai.domain.openai.model.valobj.ModelTypeVO;
import com.yzh.openai.domain.openai.service.channel.model.ModelTypeSelector;
import com.yzh.openai.domain.openai.service.channel.model.impl.GlmImageGenerator;
import com.yzh.openai.domain.openai.service.channel.model.impl.GlmTextGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Service
public class ChatGLMFactory implements ModelGroup {
    public final Map<ModelTypeVO, ModelTypeSelector> modelTypeSelectorMap = new HashMap<>();
    
    public ChatGLMFactory(GlmImageGenerator glmImageGenerator, GlmTextGenerator glmTextGenerator) {
        modelTypeSelectorMap.put(ModelTypeVO.TEXT, glmTextGenerator);
        modelTypeSelectorMap.put(ModelTypeVO.IMAGE, glmImageGenerator);
    }

    @Override
    public void doMessageResponse(ChatProcessAggregate chatProcess, ResponseBodyEmitter emitter) {
        modelTypeSelectorMap.get(chatProcess.getModelType()).doMessageResponse(chatProcess, emitter);
    }
}
